import * as actionTypes from "./constants"
import { getTopList, getRankingList } from "@/services/ranking"
const changeTopListAction = (topList) => ({
    type: actionTypes.CHANGE_TOPLIST,
    topList
})

export const getTopListAction = () => {
    return dispatch => {
        getTopList().then((res) => {
            //console.log(res.list)
            dispatch(changeTopListAction(res.list))
        })
    }
}

export const changeTopListIndexAction = (topListIndex) => ({
    type: actionTypes.CHANGR_TOPLIST_INDEX,
    topListIndex
})

const changePlayListDetailAction = (playListDetail) => ({
    type: actionTypes.CHANGE_PLAYLIST_DETAIL,
    playListDetail
})
export const getPlayListDetailAction = (id) => {
    return dispatch => {
        getRankingList(id).then(res => {
            console.log(res.playlist)
            dispatch(changePlayListDetailAction(res.playlist))
        })
    }
}